package chapter5

import (
	"fmt"
)

func Test4()  {
	type user struct {
		namew string
		age int
	}
	u1:=user{"wnag",10}
	u2:=user{
		namew: "li",
	}
	fmt.Println(u1,u2)
	fmt.Println("----------------------------")
	type student struct {
		grade int
		people struct{//内嵌一个匿名结构体要使用stu1.people.name="ss"方式来进行初始化,且字段名字如果全部相等可以直接初始化结构体
			name string
			age int
		}
	}
	stu1:=student{
		grade: 10,
	}
	stu1.people.name="ss"
	fmt.Println(stu1)
	fmt.Println("------------------------------------")
	type admin struct {//只有字段中的类型全部相等才可以比较
		name string
		age []int
	}
	a1:=admin{"w",[]int{2}}
	a2:=admin{"w",[]int{2}}
	fmt.Println(a1,a2)
	fmt.Println("----------------------------------------")
	type user2 struct {
		name string
		age int
	}
	k:=user{
		namew: "",
		age:   0,
	}
	k2:=user2{
		name: "",
		age:0,
	}
	fmt.Println(k,k2)//类型不匹配无法比较
	fmt.Println("---------------------------------------------")
	p:=&k
	p.namew="wang"
	p.age=10
	fmt.Println(k)
	p2:=&p
	(*p2).namew="ww"
	fmt.Println(k)

}

